import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'
const publicKey = `MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCO891l4spfkAtcQ2yVjJSUacd6ZiapfFuCGErZlj9WMXjmAM8LIJhlOW5SEsotbXusmCEFpbtufLqVEJchYkmM5pxLuZ4NrEduCYJiE6c65GHwKfL0FVDLz46qF8zHv6dL7VF2TJzD0pbX7nHfMBqAGTx1d6T4ORcF2xcIpc/LyQIDAQAB`
const privateKey = `MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAI7z3WXiyl+QC1xDbJWMlJRpx3pmJql8W4IYStmWP1YxeOYAzwsgmGU5blISyi1te6yYIQWlu258upUQlyFiSYzmnEu5ng2sR24JgmITpzrkYfAp8vQVUMvPjqoXzMe/p0vtUXZMnMPSltfucd8wGoAZPHV3pPg5FwXbFwilz8vJAgMBAAECgYABxBEVNTJFI7ADCeMVbMA40WuZL001Np/UdhuCzFYenBVKnxIvrwce6GQv3Jy1gRoAFLy2SrjlFjw0towG/PicWzkWvhZoj28xcsvudLlmRh8TWk+oOJ1fpcdS6CkScuLIoZW4vcyk/i+a1r11ZdFe5uyIpQBip9j52QumAfBf0QJBAL9ea5QkevnMbig+Mr02nxTIkoZm0YYxKVbE59AsjuBRB5l8ulqRtE2kxOl9O8G6DUlLyvFZu02JkT4KgUeIRbkCQQC/O2uEkYTljFNfNp5T0kvJOj2WMzJ3OCc77wF49Eb1EQay+rIGhclFNo8GWQhf4V7+wqCRhqD75BF/NRENab6RAkEAjpZMs+nmkz+GCIgniCItr++udWQg08rHkXZPfyXkIzFc5zkvJRKRdJTDf3GnV7ZH9gf6I5CHZcONq9tp7iGUSQJBAK809MxwOy/JgrVwqF0qBu+mIbkUzT73vtKlp1a3kK+F2vpuwF9DgmWcmCv7tLWMGmoVzeGnVKWUjwdainYclVECQQCgFDXNrkYlC2v6r3fNMmvr6a3Pnt8iWMBHIOmdWFW2RMk050QDY8L7uCTHpB1FzYyCorEUHMl+I5XCdvC8HyyI`

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}
